package com.lamatek.tags.google;

import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;

/**
 * GoogleMapMapTypeTag
 * 
 * This class represents a &lt;googlemaps:maptype> tag. Developers should not
 * extend this class or override it's methods.
 * 
 * @author Tom Cole
 * @version 0.85
 */
public class GoogleMapMapTypeTag extends TagSupport {

    String baseType = "map";
    String url = null;
    String lowResUrl = null;
    String overlayUrl = null;
    String name = null;
    String id = null;
    String copyright = null;
    boolean showOnStartup = true;
    int maxZoom = -1;
    int minZoom = -1;
    String upperLeftBound = null;
    String lowerRightBound = null;
    boolean png = false;
    float opacity = 1.0f;
    /**
     * Overrides doStartTag() from TagSupport. Developers should not override this method.
     */
    public int doStartTag() {
        Tag tag = this;
        while (tag.getParent() != null) {
            if (tag.getParent() instanceof GoogleMapTag) {
                ((GoogleMapTag) tag.getParent()).addMapType(this);
                return SKIP_BODY;
            }
            tag = tag.getParent();
        }
        return SKIP_BODY;
    }
    /**
     * Returns the id of the point that represents the lower right hand bounds
     * of the viewable area of this map.
     * 
     * @return A string that represents a point id.
     */
    public String getLowerRightBound() {
        return lowerRightBound;
    }
    /**
     * Sets the id of the point that represents the low right hand bounds
     * of the viewable area of this map.
     * 
     * @param point The id of a point in this map.
     */
    public void setLowerRightBound(String point) {
        this.lowerRightBound = point;
    }
    /**
     * Returns the id of the point that represents the upper left hand bounds
     * of the viewable area of this map.
     * 
     * @return A string that represents a point id.
     */
    public String getUpperLeftBound() {
        return upperLeftBound;
    }
    /**
     * Sets the id of the point that represents the upper left hand bounds
     * of the viewable area of this map.
     * 
     * @param point The id of a point in this map.
     */
    public void setUpperLeftBound(String upperLeftBound) {
        this.upperLeftBound = upperLeftBound;
    }
    /**
     * Returns the base map type from which this map type derives. 
     * 
     * @return The base map type.
     */
    public String getBaseType() {
        return baseType;
    }
    /**
     * Sets the base map type from which this map type is derived.
     * Valid values are map, satellite and hybrid.
     * 
     * @param baseType The base map type for this map type.
     */
    public void setBaseType(String baseType) {
        this.baseType = baseType;
    }
    /**
     * Returns the id for this custom map type.
     * 
     * @return The id for this map type.
     */
    public String getId() {
        return id;
    }
    /**
     * Sets the id for this map type. This should be unique within the map.
     * 
     * @param id A unique id for this map type.
     */
    public void setId(String id) {
        this.id = id;
    }
    /**
     * Returns the user viewable name for this map type. This text is placed
     * on the control button for this map type.
     * 
     * @return The name for this map type.
     */
    public String getName() {
        return name;
    }
    /**
     * Sets the user viewable name for this map type.
     * 
     * @param name A name for this map type.
     */
    public void setName(String name) {
        this.name = name;
    }
    /**
     * Returns the url for the server side process that supplies the tiles
     * for this map type.
     * 
     * @return A url to the tile generator.
     */
    public String getUrl() {
        return url;
    }
    /**
     * Sets the url for the server side process that supplied the tiles
     * for this map type.
     * 
     * @param url A url to a resource that provides map tiles for this map type.
     */
    public void setUrl(String url) {
        this.url = url;
    }
    /**
     * Denotes whether or not this map type should be initially displayed when the
     * Google Map is rendered.
     * 
     * @return True or false.
     */
    public boolean isShowOnStartup() {
        return showOnStartup;
    }
    /**
     * Sets whether or not this map type should be initially selected when the map
     * is rendered.
     * 
     * @param showOnStartup True if this map type should be initially selected, false if not.
     */
    public void setShowOnStartup(boolean showOnStartup) {
        this.showOnStartup = showOnStartup;
    }
    /**
     * Returns the url of the server side process that returns overlay tiles. This only
     * applied if this custom map is based on a hybrid map type.
     * 
     * @return A valid url to a tile generator.
     */
    public String getOverlayUrl() {
        return overlayUrl;
    }
    /**
     * Sets the url of the server side process that provides over tiles for this 
     * custom map type. This will only apply if the base map type is set to hybrid.
     * 
     * @param overlayUrl Url to the process that provides overlay tiles for this map type.
     */
    public void setOverlayUrl(String overlayUrl) {
        this.overlayUrl = overlayUrl;
    }
    /**
     * Returns the url of the server side process that returns tile images for zoom levels less than 
     * 50%.
     * 
     * @return Url to a tile generator.
     */
    public String getLowResUrl() {
        return lowResUrl;
    }
    /**
     * Set the url of the server side process that generates tiles for this map type
     * when the zoom leve is less than half way.
     * 
     * @param lowResUrl Url to a tile generator.
     */
    public void setLowResUrl(String lowResUrl) {
        this.lowResUrl = lowResUrl;
    }
    /**
     * Returns copyright information for this map type.
     * 
     * @return Copyright string.
     */
    public String getCopyright() {
        return copyright;
    }
    /**
     * Sets the copyright information for this map type.
     * 
     * @param copyright The copyright string to display when this map type is selected.
     */
    public void setCopyright(String copyright) {
        this.copyright = copyright;
    }
    /**
     * Returns the maximum zoom level supported by this map type. 
     * 
     * @return A valid zoom level as an int.
     */
    public int getMaxZoom() {
        return maxZoom;
    }
    /**
     * Sets the maximum zoom level this map type supports. When the zoom level goes past this level,
     * the default map tiles will be presented.
     * 
     * NOTE: <b>Remember that if you map is version 1, zoom levels range from 0 (all the way in) to 17 (all the way out).
     * In version 2 maps, they are reversed...</b>
     * 
     * @param maxZoom The maximum zoom level for this map type.
     */
    public void setMaxZoom(int maxZoom) {
        this.maxZoom = maxZoom;
    }
    /**
     * Returns the minimum zoom level supported by this map type. 
     * 
     * @return A valid zoom level as an int.
     */
    public int getMinZoom() {
        return minZoom;
    }
    /**
     * Sets the minimum zoom level this map type supports. When the zoom level goes past this level,
     * the default map tiles will be presented.
     * 
     * NOTE: <b>Remember that if you map is version 1, zoom levels range from 0 (all the way in) to 17 (all the way out).
     * In version 2 maps, they are reversed...</b>
     * 
     * @param minZoom The minimum zoom level for this map type.
     */
    public void setMinZoom(int minZoom) {
        this.minZoom = minZoom;
    }
    /**
     * Denotes whether or not the tiles supplied by this tile server are .png files.
     * 
     * @return True if tiles are .png format, false otherwise
     */
    public boolean isPng() {
        return png;
    }
    /**
     * Sets whether or not the tiles for this map type are .png format.
     * 
     * @param png True if tiles for this map type are .png format, false otherwise.
     */
    public void setPng(boolean png) {
        this.png = png;
    }
}
